Full source code website bán hàng thương mại điện tử gần giống shopee
468.866 lượt xem;
1 <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#0069A8" width="100%" id="AutoNumber1">
2 <tr><td width="45%" height="20" align="center" class="title">
3 Danh sách tỉnh thành | <a href="?act=city_add"><font color="#ffffff">Thên tỉnh thành</font></a>
4 </td></tr>
5 <tr><td>
6 <?
7 switch ($_GET['action'])
8 {
9 case 'del' :
10 $id = $_GET['id'];
11 $sql = "delete from city where id='".$id."'";
12 @$result = mysql_query($sql,$con);
13 if ($result) echo "<p align=center class='err'>Đã xóa thành công</p>";
14 else echo "<p align=center class='err'>Không thể xóa dữ liệu</p>";
15 break;
16 }
17 ?>
18
19 <?
20 if (isset($_POST['ButDel'])) {
21 $cnt=0;
22 foreach ($_POST['chk'] as $id)
23 {
24 @$result = mysql_query("delete from city where id='".$id."'",$con);
25 if ($result) $cnt++;
26 }
27 echo "<p align=center class='err'>Đã xóa ".$cnt." phần tử</p>";
28 }
29 ?>
30 <?
31 $page = $_GET["page"];
32 $MAXPAGE=10;
33 $p=0;
34 if ($page!='') $p=$page;
35 ?>
36
37
38 <form method="POST" action="<? echo $_SERVER[PHP_SELF]; ?>" name="frmList">
39 <input type="hidden" name="act" value="city">
40 <input type=hidden name="page" value="<? echo $page; ?>">
41 <?
42 function taotrang($sql,$link,$nitem,$itemcurrent)
43 { global $con;
44 $ret="";
45 $result = mysql_query($sql, $con) or die('Error' . mysql_error());
46 $value = mysql_fetch_array($result);
47 $plus = (($value['cnt'] % $nitem)>0);
48 for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
49 {
50 if ($i<>$itemcurrent) $ret .= "<a href=\"".$link.$i."\" class=\"lslink\">".($i+1)."</a> ";
51 else $ret .= ($i+1)." ";
52 }
53 return $ret;
54 }
55 $pageindex=taotrang("select count(*) from city","./?act=city"."&page=",$MAXPAGE,$page);
56 ?>
57
58 <table cellspacing="0" cellpadding="0">
59 <tr>
60 <td class="smallfont">Trang : <? echo $pageindex; ?></td>
61 </tr>
62 </table>
63 </td></tr>
64
65
66
67 <tr><td>
68 <!-- begin danh sach -->
69 <form method="POST" action="<? echo $_SERVER[PHP_SELF]; ?>" name="frmList">
70 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
71 <tr class="title">
72 <td align=center nowrap class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
73 <td nowrap class="title"> </td>
74 <td nowrap class="title"> </td>
75 <td>ID</td>
76 <td>Mã</td>
77 <td>Tên</td>
78 </tr>
79 <? $sql=mysql_query("SELECT * FROM city order by id desc");
80 $i=0;
81 while($row=mysql_fetch_array($sql))
82 {
83 $i++;
84 if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
85 ?>
86
87 <tr bgcolor="<? echo $color;?>">
88 <td width="20" align="center" class="smallfont"><input type="checkbox" name="chk[]" value="<? echo $row['id']; ?>"></td>
89 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
90 <a href="./?act=city_add&cat=<? echo $_REQUEST['cat']; ?>&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['id']; ?>">
91 Sửa</a></td>
92 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
93 <a href="./?act=city&action=del&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['id']; ?>">
94 Xoá</a></td>
95 <td><? echo $row['id'];?></td>
96 <td><? echo $row['code'];?></td>
97 <td><? echo $row['name'];?></td>
98 </td>
99
100 </tr>
101 <?}?>
102 </table>
103 </form>
104 <!-- end danh sach -->
105
106
107
108 </td></tr>
109 </table>
110 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button" style="padding: 0">
111 <input type="hidden" name="act" value="users">
112 <script language="JavaScript">
113 function chkallClick(o) {
114 var form = document.frmList;
115 for (var i = 0; i < form.elements.length; i++) {
116 if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
117 form.elements[i].checked = document.frmList.chkall.checked;
118 }
119 }
120 }
121 </script>
2 <tr><td width="45%" height="20" align="center" class="title">
3 Danh sách tỉnh thành | <a href="?act=city_add"><font color="#ffffff">Thên tỉnh thành</font></a>
4 </td></tr>
5 <tr><td>
6 <?
7 switch ($_GET['action'])
8 {
9 case 'del' :
10 $id = $_GET['id'];
11 $sql = "delete from city where id='".$id."'";
12 @$result = mysql_query($sql,$con);
13 if ($result) echo "<p align=center class='err'>Đã xóa thành công</p>";
14 else echo "<p align=center class='err'>Không thể xóa dữ liệu</p>";
15 break;
16 }
17 ?>
18
19 <?
20 if (isset($_POST['ButDel'])) {
21 $cnt=0;
22 foreach ($_POST['chk'] as $id)
23 {
24 @$result = mysql_query("delete from city where id='".$id."'",$con);
25 if ($result) $cnt++;
26 }
27 echo "<p align=center class='err'>Đã xóa ".$cnt." phần tử</p>";
28 }
29 ?>
30 <?
31 $page = $_GET["page"];
32 $MAXPAGE=10;
33 $p=0;
34 if ($page!='') $p=$page;
35 ?>
36
37
38 <form method="POST" action="<? echo $_SERVER[PHP_SELF]; ?>" name="frmList">
39 <input type="hidden" name="act" value="city">
40 <input type=hidden name="page" value="<? echo $page; ?>">
41 <?
42 function taotrang($sql,$link,$nitem,$itemcurrent)
43 { global $con;
44 $ret="";
45 $result = mysql_query($sql, $con) or die('Error' . mysql_error());
46 $value = mysql_fetch_array($result);
47 $plus = (($value['cnt'] % $nitem)>0);
48 for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
49 {
50 if ($i<>$itemcurrent) $ret .= "<a href=\"".$link.$i."\" class=\"lslink\">".($i+1)."</a> ";
51 else $ret .= ($i+1)." ";
52 }
53 return $ret;
54 }
55 $pageindex=taotrang("select count(*) from city","./?act=city"."&page=",$MAXPAGE,$page);
56 ?>
57
58 <table cellspacing="0" cellpadding="0">
59 <tr>
60 <td class="smallfont">Trang : <? echo $pageindex; ?></td>
61 </tr>
62 </table>
63 </td></tr>
64
65
66
67 <tr><td>
68 <!-- begin danh sach -->
69 <form method="POST" action="<? echo $_SERVER[PHP_SELF]; ?>" name="frmList">
70 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
71 <tr class="title">
72 <td align=center nowrap class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
73 <td nowrap class="title"> </td>
74 <td nowrap class="title"> </td>
75 <td>ID</td>
76 <td>Mã</td>
77 <td>Tên</td>
78 </tr>
79 <? $sql=mysql_query("SELECT * FROM city order by id desc");
80 $i=0;
81 while($row=mysql_fetch_array($sql))
82 {
83 $i++;
84 if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
85 ?>
86
87 <tr bgcolor="<? echo $color;?>">
88 <td width="20" align="center" class="smallfont"><input type="checkbox" name="chk[]" value="<? echo $row['id']; ?>"></td>
89 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
90 <a href="./?act=city_add&cat=<? echo $_REQUEST['cat']; ?>&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['id']; ?>">
91 Sửa</a></td>
92 <td width="20" bgcolor="<? echo $color; ?>" class="smallfont">
93 <a href="./?act=city&action=del&page=<? echo $_REQUEST['page']; ?>&id=<? echo $row['id']; ?>">
94 Xoá</a></td>
95 <td><? echo $row['id'];?></td>
96 <td><? echo $row['code'];?></td>
97 <td><? echo $row['name'];?></td>
98 </td>
99
100 </tr>
101 <?}?>
102 </table>
103 </form>
104 <!-- end danh sach -->
105
106
107
108 </td></tr>
109 </table>
110 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button" style="padding: 0">
111 <input type="hidden" name="act" value="users">
112 <script language="JavaScript">
113 function chkallClick(o) {
114 var form = document.frmList;
115 for (var i = 0; i < form.elements.length; i++) {
116 if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
117 form.elements[i].checked = document.frmList.chkall.checked;
118 }
119 }
120 }
121 </script>